package cn.tdeu.spring.eg3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class ShopController {
    private String name;

    public ShopController() {
        System.out.println("1.创建对象");
    }

    @Value("小红")
    public void setName(String name) {
        this.name = name;
        System.out.println("2.set方法属性赋值");
    }
    @PostConstruct
    public void init() {
        System.out.println("3.初始化方法");
    }
    @PreDestroy
    public void saas(){
        System.out.println("5.销毁方法");
    }

    @Override
    public String toString() {
        return "ShopController{" +
                "name='" + name + '\'' +
                '}';
    }
}
